package com.sie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sie.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 用户持久层
 */
@Mapper
public interface EmpMapper extends BaseMapper<Emp> {

    List<ViewEmp> findByPage(@Param("emp") ViewEmp emp, @Param("bigTime") String big, @Param("small") String small);


    @Select("SELECT a.* FROM authority a LEFT JOIN role_authority t  ON t.authority_id= a.auth_id WHERE role_id =#{id}")
    List<Authority> authors(@Param("id") String id);


    Integer update(@Param("user") ViewEmp user);

    @Select("select * from view_emp_login where login_name=#{loginName}")
    ViewEmpLogin findByNameToEmp(@Param("loginName") String loginName);

    int addEmp(ViewEmp entity);

    @Select("select * from view_emp where emp_id=#{id}")
    ViewEmp selectById(String id);
//    @Select("select * from login where login_name=#{loginName}")
//    ViewEmpLogin loginNameDetection(@Param("loginName") String loginName);

    @Delete("delete from emp where emp_id=#{id}")
    int deleteById(String id);

    @Delete("delete from emp_role where emp_id=#{id}")
    int deleteIdAndRole(String id);

    @Delete("delete from emp_login where emp_id=#{id}")
    int deleteIdAndLogin(String id);

    @Select("select * from emp_login where emp_id=#{id}")
    EmpLogin findLoginByEmpId(String id);


}
